$(function()
{
    console.log('jquery start');
});

document.addEventListener('DOMContentLoaded', function(){

    document.querySelector('#SaveButton').addEventListener('click', function(){
        localStorage['RefreshTime'] = parseInt( $('#RefreshTime').val() );
        localStorage['UrlInput'] = $('#UrlInput').val();
        localStorage['AlwaysRefresh'] = $('#AlwaysRefresh').prop( "checked" );
        localStorage['RefreshHost'] = $('#RefreshHost').val();
        $('#Info').html('已保存!');
    });
    document.querySelector('#TestLink').addEventListener('click', function(){
        $.ajax({
            url:$('#UrlInput').val(),
            type:'get',
            dataType:'text',
            success:function(response){
                alert(response);
            }
        });
    });
    if(localStorage['RefreshTime'] != undefined )
    {
        $('#RefreshTime').val(localStorage['RefreshTime']);
    }
    if(localStorage['UrlInput'] != undefined )
    {
        $('#UrlInput').val(localStorage['UrlInput']);
    }
    if(localStorage['AlwaysRefresh'] == 'true' )
    {
        $('#AlwaysRefresh').prop( "checked", true);
    }
    if(localStorage['RefreshHost'] != undefined )
    {
        $('#RefreshHost').val( localStorage['RefreshHost'] );
    }
});
